package cn.webrx;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>Description: 实现Set集合排序，先转换类型为有序集合
 * <p>Class: Set4
 * <p>Powered by webrx On 2022-06-16 9:38
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since   17
 */
public class Set4 {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>(List.of("java","c","go","c++","python"));
        System.out.println("Set:"+set);

        //Set 转换为List

        List<String> list = new ArrayList<>(set);
        System.out.println("List:"+list);
        list.sort((a,b)->a.compareTo(b));
        System.out.println("List字符升序："+list);

        Set<String> aaa = new HashSet<>(list);
        System.out.println("Set:"+aaa);
    }
}
